package com.jeecms.wicool.dao.lottery.impl;


import java.util.List;

import org.springframework.stereotype.Repository;

import com.jeecms.cms.entity.main.CmsUser;
import com.jeecms.common.hibernate3.Finder;
import com.jeecms.common.hibernate3.HibernateBaseDao;
import com.jeecms.wicool.dao.lottery.LotteryConfigDao;
import com.jeecms.wicool.entity.lottery.LotteryConfig;

@Repository
public class LotteryConfigDaoImpl extends
		HibernateBaseDao<LotteryConfig, Integer> implements LotteryConfigDao {
	
	@Override
	protected Class<LotteryConfig> getEntityClass() {
		// TODO Auto-generated method stub
		return LotteryConfig.class;
	}

	
	@Override
	public LotteryConfig findById(Integer id) {
		LotteryConfig entity = get(id);
		return entity;
	}
	@Override
	public LotteryConfig save(LotteryConfig bean) {
		getSession().save(bean);
		return bean;
	}
	@Override
	public LotteryConfig deleteById(Integer id) {
		LotteryConfig entity = super.get(id);
		if (entity != null) {
			getSession().delete(entity);
		}
		return entity;
	}

	@Override
	public List<LotteryConfig> getAll(CmsUser user) {
		Finder f= Finder.create("select bean from LotteryConfig bean where 1=1 ");
		f.append(" order by bean.id desc");
		return find(f);
	}
}